<?php
$username = "fossilplot";
$password = "fossilplot";
$hostname = "localhost"; 

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
 or die("Unable to connect to MySQL");
echo "Connected to MySQL<br>";

//select a database to work with
$selected = mysql_select_db("fossilplot",$dbhandle)
  or die("Could not select examples");

//execute the SQL query and return records
$result = mysql_query("select fad_date, lad_date, count(*) from genus where class_id in (5) or phylum_id in (3) or order_id in (44,45,373) GROUP BY fad_date, lad_date order by fad_date desc;");

//fetch tha data from the database
$total=0;
while ($row = mysql_fetch_array($result)) {
   echo "fad_date:".$row{'fad_date'}." "."lad_date:".$row{'lad_date'}." "."count:".$row{'count(*)'}."<br>";
   $total = $total+ $row{'count(*)'};
}

echo "total is ".$total;
//close the connection
mysql_close($dbhandle);
?>